import { axiosInstance } from 'src/boot/axios'

// 密码登录
export function loginPas (phone, password) {
  const newUrl = '/login/password'
  let data = {
    phone, password
  }

  return axiosInstance.post(newUrl, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 手机号登录
export function loginPhone (phone, code) {
  const newUrl = '/login/phone'
  let data = {
    phone, code
  }

  return axiosInstance.post(newUrl, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 注销
export function loginOut () {
  const newUrl = '/login/logout'

  return axiosInstance.get(newUrl).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 重置密码
export function reset (phone, code, newPassword) {
  const newUrl = '/login/reset'
  let data = {
    phone, code, newPassword
  }

  return axiosInstance.post(newUrl, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取验证码
export function getCode (phone) {
  const newUrl = '/login/getCode'
  let data = {
    phone
  }

  return axiosInstance.post(newUrl, data).then((res) => {
    return Promise.resolve(res.data)
  })
}

// 获取账号信息
export function getInfo () {
  const newUrl = '/login/getInfo'

  return axiosInstance.get(newUrl).then((res) => {
    return Promise.resolve(res.data)
  })
}
